package com.project.controller;

import com.project.bean.CutPageBean;
import com.project.bean.ThemeBean;
import com.project.service.IThemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
@SuppressWarnings("all")
@RestController
@RequestMapping("theme")
public class ThemeController {
    @Autowired
    IThemeService service;

    @RequestMapping("findByItem")
    public CutPageBean<ThemeBean> findByItem(Integer pageNO, Integer channelId, String name, String username, LocalDate startDate, LocalDate endDate) {
        return service.findByItem(pageNO, channelId, name, username, startDate, endDate);
    }

    /**
     * 发帖
     *
     * @param
     * @return 发布成功 返回ok
     */
    @RequestMapping("add")
    public String add(String name,String content,Integer userId,Integer channelId) {
        ThemeBean theme = new ThemeBean(name,userId,content,channelId);
        service.add(theme);
        return "ok";
    }

    /**
     * 按编号查询帖子详情
     *
     * @param id 编号
     * @return 帖子对象
     */
    @RequestMapping("findById")
    public ThemeBean findById(Integer id) {
        return service.findById(id);
    }
}
